package com.letoken.platform.pub.enums;

/**
 * 后台操作日志操作类型枚举
 *
 * @author : hfanghao
 * @date : 2022-01-20 16:11
 **/
public enum AdminOperationLogTypeEnum {
    ADD("add", 1),
    CREATE("create", 1),
    PAGE("page", 1),
    UPDATE("update", 2),
    EDIT("edit", 2),
    DELETE("del", 3),
    QUERY("query", 4),
    SELECT("select", 4),
    UNKNOWN("unknown", 5);

    private String name;
    private int code;

    AdminOperationLogTypeEnum(String name, int code) {
        this.name = name;
        this.code = code;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public static Integer  getLogTypeCode(String operionName) {
        for (AdminOperationLogTypeEnum adminOperationLogTypeEnum : values()) {
            if (operionName.contains(adminOperationLogTypeEnum.name)) {
                return adminOperationLogTypeEnum.code;
            }
        }
        return AdminOperationLogTypeEnum.UNKNOWN.code;
    }
}
